﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/AdminPage.master" AutoEventWireup="true" CodeFile="Customer_Management.aspx.cs" Inherits="Admin_CustomerManagement" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table class="style3" align="center" border="0">
        <tr>
            <td style="background-image: url('../images/bg_head.png'); height: 30px;" colspan="4" 
            class="style3">
                <asp:Label ID="Label3" runat="server" ForeColor="White" Text="Customer Management" 
                    Font-Bold="True" ></asp:Label>
            </td>
        </tr>
        <tr>
            <td style="width: 41px">
                &nbsp;</td>
            <td style="width: 153px">
                &nbsp;</td>
            <td class="style4" style="width: 159px">
            &nbsp;</td>
            <td>
            &nbsp;</td>
        </tr>
        <tr>
            <td style="width: 41px">
            </td>
            <td style="width: 153px">
                <asp:Label ID="Label2" runat="server" Font-Bold="True" Text="Customer Name:"></asp:Label>
            </td>
            <td class="style4" style="width: 159px">
                <asp:TextBox ID="txtSearchCustName" runat="server" Width="160px"></asp:TextBox>
            </td>
            <td>
                <asp:ImageButton ID="imgbSearch" runat="server" 
                    ImageUrl="~/images/img_Search.png" />
                <asp:ImageButton ID="imgbShowAll" runat="server" 
                    ImageUrl="~/images/img_Show All.png" onclick="imgbShowAll_Click" />
            </td>
        </tr>
        <tr>
            <td style="width: 41px">
            </td>
            <td colspan="3">
                &nbsp;</td>
        </tr>
        <tr>
            <td style="width: 41px">
            </td>
            <td colspan="3" align="center">
                <asp:GridView ID="gvCustomer" runat="server" AllowPaging="True" 
                    AutoGenerateColumns="False" CellPadding="4" CssClass="style3" 
                    DataKeyNames="CustID" DataSourceID="SqlDataSource1" 
                    EmptyDataText="There are no data records to display." ForeColor="#333333" 
                    GridLines="None" onrowcommand="gvCustomer_RowCommand" Width="519px" 
                    style="margin-right: 1px">
                    <AlternatingRowStyle BackColor="White" />
                    <Columns>
                        <asp:BoundField DataField="CustID" HeaderText="CustomerID" ReadOnly="True" 
                            SortExpression="CustID" />
                        <asp:BoundField DataField="AccID" HeaderText="AccountID" 
                            SortExpression="AccID" />
                        <asp:BoundField DataField="Cust_Name" HeaderText="CustomerName" 
                            SortExpression="Cust_Name" />
                        <asp:BoundField DataField="DateCreated" HeaderText="DateCreated" 
                            SortExpression="DateCreated" />
                        <asp:BoundField DataField="Cust_Status" HeaderText="Status" 
                            SortExpression="Cust_Status" />
                        <asp:TemplateField HeaderText="Details">
                            <ItemTemplate>
                                <asp:ImageButton ID="imgbDetails" runat="server" 
                                    CommandArgument='<%# Eval("CustID") %>' CommandName="Details" 
                                    ImageUrl="~/images/img_Details.png" />
                            </ItemTemplate>
                            <ControlStyle Height="25px" Width="75px" />
                        </asp:TemplateField>
                        <asp:CommandField ButtonType="Image" DeleteImageUrl="~/images/img_Delete.png" 
                            HeaderText="Delete" ShowDeleteButton="True">
                        <ControlStyle Height="25px" Width="75px" />
                        </asp:CommandField>
                    </Columns>
                    <EditRowStyle BackColor="#2461BF" />
                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#EFF3FB" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#F5F7FB" />
                    <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                    <SortedDescendingCellStyle BackColor="#E9EBEF" />
                    <SortedDescendingHeaderStyle BackColor="#4870BE" />
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:OPOConnectionString %>" 
                    DeleteCommand="DELETE FROM [Customer] WHERE [CustID] = @CustID" 
                    InsertCommand="INSERT INTO [Customer] ([AccID], [Cust_Name], [Cust_Email], [Cust_Birthday], [Cust_Gender], [Cust_Address], [Cust_Phone], [DateCreated], [Cust_Status]) VALUES (@AccID, @Cust_Name, @Cust_Email, @Cust_Birthday, @Cust_Gender, @Cust_Address, @Cust_Phone, @DateCreated, @Cust_Status)" 
                    ProviderName="<%$ ConnectionStrings:OPOConnectionString.ProviderName %>" 
                    SelectCommand="SELECT [CustID], [AccID], [Cust_Name], [Cust_Email], [Cust_Birthday], [Cust_Gender], [Cust_Address], [Cust_Phone], [DateCreated], [Cust_Status] FROM [Customer] WHERE ([Cust_Name] LIKE '%' + @Cust_Name + '%')" 
                    
                    UpdateCommand="UPDATE [Customer] SET [AccID] = @AccID, [Cust_Name] = @Cust_Name, [Cust_Email] = @Cust_Email, [Cust_Birthday] = @Cust_Birthday, [Cust_Gender] = @Cust_Gender, [Cust_Address] = @Cust_Address, [Cust_Phone] = @Cust_Phone, [DateCreated] = @DateCreated, [Cust_Status] = @Cust_Status WHERE [CustID] = @CustID">
                    <DeleteParameters>
                        <asp:Parameter Name="CustID" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="AccID" Type="Int32" />
                        <asp:Parameter Name="Cust_Name" Type="String" />
                        <asp:Parameter Name="Cust_Email" Type="String" />
                        <asp:Parameter Name="Cust_Birthday" Type="String" />
                        <asp:Parameter Name="Cust_Gender" Type="String" />
                        <asp:Parameter Name="Cust_Address" Type="String" />
                        <asp:Parameter Name="Cust_Phone" Type="String" />
                        <asp:Parameter Name="DateCreated" Type="String" />
                        <asp:Parameter Name="Cust_Status" Type="String" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="txtSearchCustName" DefaultValue="%" 
                            Name="Cust_Name" PropertyName="Text" Type="String" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="AccID" Type="Int32" />
                        <asp:Parameter Name="Cust_Name" Type="String" />
                        <asp:Parameter Name="Cust_Email" Type="String" />
                        <asp:Parameter Name="Cust_Birthday" Type="String" />
                        <asp:Parameter Name="Cust_Gender" Type="String" />
                        <asp:Parameter Name="Cust_Address" Type="String" />
                        <asp:Parameter Name="Cust_Phone" Type="String" />
                        <asp:Parameter Name="DateCreated" Type="String" />
                        <asp:Parameter Name="Cust_Status" Type="String" />
                        <asp:Parameter Name="CustID" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td style="width: 41px">
                &nbsp;</td>
            <td colspan="3">
                &nbsp;</td>
        </tr>
    </table>
</asp:Content>

